import { Controller, Post, Body, UseGuards, Get, Query } from '@nestjs/common';
import { NoticeService } from './notice.service';
import { CreateNoticeDto } from './dto/create-notice.dto';
import { AuthGuard } from 'src/gurad/auth/auth.guard';
@UseGuards(AuthGuard)
@Controller('notice')
export class NoticeController {
  constructor(private readonly noticeService: NoticeService) {}


  /**
   * 创建公告
  */
  @Post('add')
  create(@Body() createNoticeDto: CreateNoticeDto) {
    return this.noticeService.create(createNoticeDto);
  }

  /**
   * 获取公告列表
   */
  @Get('query')
  query(@Query() queryInfo){
    return this.noticeService.query({
      ...queryInfo,
      currentPage: +queryInfo.currentPage,
      pageSize: +queryInfo.pageSize,
    });
  }
  
    /**
 * 删除公告
 */
    @Post('delete')
    delete(@Body() queryInfo) {
      return this.noticeService.delete(queryInfo.id);
    }

      /**
   * 发布公告
  */
 @Post('publish')
 publish(@Body() info) {
  return this.noticeService.publish(info)
 }

  /**
    * 更新公告
  */
  @Post('update')
  update(@Body() info) {
    return this.noticeService.update(info)
  }
}
